/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ru.jSkyRoom.bridge.major;

import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import ru.jSkyRoom.bridge.IteratorFormIdFinder;
import ru.jSkyRoom.interfaces.major.FormList;
import ru.jSkyRoom.interfaces.major.Major;
import skyproc.FLST;
import skyproc.FormID;

/**
 *
 * @author Rakev
 */
public class FormListBridge extends MajorBridge<FLST> implements FormList {

    public FormListBridge(FLST adapting) {
        super(adapting);
    }

    @Override
    public Collection<Major> getEntries() {
        Collection<FormID> formIds = getRawObject().getFormIDEntries();
        Collection<Major> entrys = getFinderFactory().createMajorFinder().find(formIds);

        return Collections.unmodifiableCollection(entrys);
    }

    @Override
    public void addEntry(Major entry) {
        getRawObject().addFormEntry(entry.getForm());
    }

    @Override
    public void removeEntry(Major entry) {
        getRawObject().removeFormEntry(entry.getForm());
    }

    @Override
    public Iterator<Major> iterator() {
        Iterator<FormID> rawIterator = getRawObject().getFormIDEntries().iterator();
        return new IteratorFormIdFinder<>(rawIterator);
    }
}
